]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
js: Simplify promisify() calls
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 10 Feb 2022 23:09:54 +0000 (00:09 +0100)
committerMarge Bot <marge-bot@gnome.org>
Fri, 11 Feb 2022 16:24:01 +0000 (16:24 +0000)
If the finish function isn't specified, promisify will now try
to use the async name without '_async'/'_begin' suffix (if any)
and '_finish' appended.

Everything except IBus uses a variation of that pattern, so there's
quite a bit of boilerplate we get to remove…

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2174>

14 files changed:
js/dbusServices/notifications/notificationDaemon.js
js/gdm/util.js
js/misc/parentalControlsManager.js
js/misc/weather.js
js/ui/background.js
js/ui/components/networkAgent.js
js/ui/components/telepathyClient.js
js/ui/environment.js
js/ui/extensionDownloader.js
js/ui/main.js
js/ui/screenshot.js
js/ui/status/network.js
js/ui/windowManager.js
subprojects/extensions-app/js/main.js

index 139075256e5d793a0b3e6b8efc386e07f57cf2b3..d0c97860cb04818e22bd7b56658dc3fc3b312a91 100644 (file)
@@ -9,7 +9,7 @@ const { ServiceImplementation } = imports.dbusService;
 const NotificationsIface = loadInterfaceXML('org.freedesktop.Notifications');
 const NotificationsProxy = Gio.DBusProxy.makeProxyWrapper(NotificationsIface);
 
-Gio._promisify(Gio.DBusConnection.prototype, 'call', 'call_finish');
+Gio._promisify(Gio.DBusConnection.prototype, 'call');
 
 var NotificationDaemon = class extends ServiceImplementation {
     constructor() {
index b5f31a2ffc992277d5089bd51841f78fe3c2f057..d310099a619cecf6c45b6daed582544ae6430adc 100644 (file)
@@ -18,14 +18,11 @@ const FprintManagerProxy = Gio.DBusProxy.makeProxyWrapper(FprintManagerIface);
 const FprintDeviceIface = loadInterfaceXML('net.reactivated.Fprint.Device');
 const FprintDeviceProxy = Gio.DBusProxy.makeProxyWrapper(FprintDeviceIface);
 
-Gio._promisify(Gdm.Client.prototype,
-    'open_reauthentication_channel', 'open_reauthentication_channel_finish');
-Gio._promisify(Gdm.Client.prototype,
-    'get_user_verifier', 'get_user_verifier_finish');
+Gio._promisify(Gdm.Client.prototype, 'open_reauthentication_channel');
+Gio._promisify(Gdm.Client.prototype, 'get_user_verifier');
 Gio._promisify(Gdm.UserVerifierProxy.prototype,
-    'call_begin_verification_for_user', 'call_begin_verification_for_user_finish');
-Gio._promisify(Gdm.UserVerifierProxy.prototype,
-    'call_begin_verification', 'call_begin_verification_finish');
+    'call_begin_verification_for_user');
+Gio._promisify(Gdm.UserVerifierProxy.prototype, 'call_begin_verification');
 
 var PASSWORD_SERVICE_NAME = 'gdm-password';
 var FINGERPRINT_SERVICE_NAME = 'gdm-fingerprint';
index fc1e7ced6f54d2ace58842c851b56ef2e2a0e88a..092721133aa4ee0f811f08e6abb81578a1e59831 100644 (file)
@@ -32,7 +32,7 @@ const HAVE_MALCONTENT = imports.package.checkSymbol(
 var Malcontent = null;
 if (HAVE_MALCONTENT) {
     Malcontent = imports.gi.Malcontent;
-    Gio._promisify(Malcontent.Manager.prototype, 'get_app_filter_async', 'get_app_filter_finish');
+    Gio._promisify(Malcontent.Manager.prototype, 'get_app_filter_async');
 }
 
 let _singleton = null;
index 2c7480a7d0333f8e4f53c24664598fa5c8d03283..1cd4e38ee3871a566039073087a2d420e61385bc 100644 (file)
@@ -7,7 +7,7 @@ const PermissionStore = imports.misc.permissionStore;
 
 const { loadInterfaceXML } = imports.misc.fileUtils;
 
-Gio._promisify(Geoclue.Simple, 'new', 'new_finish');
+Gio._promisify(Geoclue.Simple, 'new');
 
 const WeatherIntegrationIface = loadInterfaceXML('org.gnome.Shell.WeatherIntegration');
 
index 7a22e803bb08c8123cd893941b196b86d9b5a027..a3389c7926fa6f821c01b75d592418c84156f78f 100644 (file)
@@ -101,7 +101,7 @@ const LoginManager = imports.misc.loginManager;
 const Main = imports.ui.main;
 const Params = imports.misc.params;
 
-Gio._promisify(Gio.File.prototype, 'query_info_async', 'query_info_finish');
+Gio._promisify(Gio.File.prototype, 'query_info_async');
 
 var DEFAULT_BACKGROUND_COLOR = Clutter.Color.from_pixel(0x2e3436ff);
 
index 8c8d8451b81bff14f7f0203ee1814a969dd7878f..68ac05f0cc57e1c017441d6d061bdd1a23503163 100644 (file)
@@ -10,9 +10,8 @@ const MessageTray = imports.ui.messageTray;
 const ModalDialog = imports.ui.modalDialog;
 const ShellEntry = imports.ui.shellEntry;
 
-Gio._promisify(Shell.NetworkAgent.prototype, 'init_async', 'init_finish');
-Gio._promisify(Shell.NetworkAgent.prototype,
-    'search_vpn_plugin', 'search_vpn_plugin_finish');
+Gio._promisify(Shell.NetworkAgent.prototype, 'init_async');
+Gio._promisify(Shell.NetworkAgent.prototype, 'search_vpn_plugin');
 
 const VPN_UI_GROUP = 'VPN Plugin UI';
 
index 103688259cbfd3b1ac1bdce225d679bbd7ca8fe7..859a7e64fb8a7573c809f2ce2e125fd4f468cfbd 100644 (file)
@@ -8,13 +8,10 @@ var Tp = null;
 try {
     ({ TelepathyGLib: Tp, TelepathyLogger: Tpl } = imports.gi);
 
-    Gio._promisify(Tp.Channel.prototype, 'close_async', 'close_finish');
-    Gio._promisify(Tp.TextChannel.prototype,
-        'send_message_async', 'send_message_finish');
-    Gio._promisify(Tp.ChannelDispatchOperation.prototype,
-        'claim_with_async', 'claim_with_finish');
-    Gio._promisify(Tpl.LogManager.prototype,
-        'get_filtered_events_async', 'get_filtered_events_finish');
+    Gio._promisify(Tp.Channel.prototype, 'close_async');
+    Gio._promisify(Tp.TextChannel.prototype, 'send_message_async');
+    Gio._promisify(Tp.ChannelDispatchOperation.prototype, 'claim_with_async');
+    Gio._promisify(Tpl.LogManager.prototype, 'get_filtered_events_async');
 } catch (e) {
     log('Telepathy is not available, chat integration will be disabled.');
 }
index 37c854cc36ac7d1da70308d16d1488f3d49a23eb..e1225257bd748c4dc03b68e150b0caf003786745 100644 (file)
@@ -28,16 +28,14 @@ const { Clutter, Gio, GLib, GObject, Meta, Polkit, Shell, St } = imports.gi;
 const Gettext = imports.gettext;
 const System = imports.system;
 
-Gio._promisify(Gio.DataInputStream.prototype, 'fill_async', 'fill_finish');
-Gio._promisify(Gio.DataInputStream.prototype,
-    'read_line_async', 'read_line_finish');
-Gio._promisify(Gio.DBus, 'get', 'get_finish');
-Gio._promisify(Gio.DBusConnection.prototype, 'call', 'call_finish');
-Gio._promisify(Gio.DBusProxy, 'new', 'new_finish');
-Gio._promisify(Gio.DBusProxy.prototype, 'init_async', 'init_finish');
-Gio._promisify(Gio.DBusProxy.prototype,
-    'call_with_unix_fd_list', 'call_with_unix_fd_list_finish');
-Gio._promisify(Polkit.Permission, 'new', 'new_finish');
+Gio._promisify(Gio.DataInputStream.prototype, 'fill_async');
+Gio._promisify(Gio.DataInputStream.prototype, 'read_line_async');
+Gio._promisify(Gio.DBus, 'get');
+Gio._promisify(Gio.DBusConnection.prototype, 'call');
+Gio._promisify(Gio.DBusProxy, 'new');
+Gio._promisify(Gio.DBusProxy.prototype, 'init_async');
+Gio._promisify(Gio.DBusProxy.prototype, 'call_with_unix_fd_list');
+Gio._promisify(Polkit.Permission, 'new');
 
 let _localTimeZone = null;
 
index 8bf4646a6aa3080df709d3436a1da0e534776566..a3cfbf3f55d327b5a60ea5446c86f958de5b8289 100644 (file)
@@ -10,14 +10,10 @@ const FileUtils = imports.misc.fileUtils;
 const Main = imports.ui.main;
 const ModalDialog = imports.ui.modalDialog;
 
-Gio._promisify(Soup.Session.prototype,
-    'send_and_read_async', 'send_and_read_finish');
-Gio._promisify(Gio.OutputStream.prototype,
-    'write_bytes_async', 'write_bytes_finish');
-Gio._promisify(Gio.IOStream.prototype,
-    'close_async', 'close_finish');
-Gio._promisify(Gio.Subprocess.prototype,
-    'wait_check_async', 'wait_check_finish');
+Gio._promisify(Soup.Session.prototype, 'send_and_read_async');
+Gio._promisify(Gio.OutputStream.prototype, 'write_bytes_async');
+Gio._promisify(Gio.IOStream.prototype, 'close_async');
+Gio._promisify(Gio.Subprocess.prototype, 'wait_check_async');
 
 var REPOSITORY_URL_DOWNLOAD = 'https://extensions.gnome.org/download-extension/%s.shell-extension.zip';
 var REPOSITORY_URL_INFO     = 'https://extensions.gnome.org/extension-info/';
index 8fa25bc43cdc5ba6c087861420b6e0dff3137220..ce019471b5ef9d5a45b8343f38590beab8c6f8e7 100644 (file)
@@ -100,8 +100,8 @@ let _themeResource = null;
 let _oskResource = null;
 let _iconResource = null;
 
-Gio._promisify(Gio.File.prototype, 'delete_async', 'delete_finish');
-Gio._promisify(Gio.File.prototype, 'touch_async', 'touch_finish');
+Gio._promisify(Gio.File.prototype, 'delete_async');
+Gio._promisify(Gio.File.prototype, 'touch_async');
 
 let _remoteAccessInhibited = false;
 
index f35ab6034e0c1e1fc9a84bf878ab65a58c2a010b..c846721aa1d6510994c2f7bfeb8138c8e75a57b2 100644 (file)
@@ -10,17 +10,12 @@ const Main = imports.ui.main;
 const MessageTray = imports.ui.messageTray;
 const Workspace = imports.ui.workspace;
 
-Gio._promisify(Shell.Screenshot.prototype, 'pick_color', 'pick_color_finish');
-Gio._promisify(Shell.Screenshot.prototype, 'screenshot', 'screenshot_finish');
-Gio._promisify(Shell.Screenshot.prototype,
-    'screenshot_window', 'screenshot_window_finish');
-Gio._promisify(Shell.Screenshot.prototype,
-    'screenshot_area', 'screenshot_area_finish');
-Gio._promisify(Shell.Screenshot.prototype,
-    'screenshot_stage_to_content', 'screenshot_stage_to_content_finish');
-Gio._promisify(
-    Shell.Screenshot,
-    'composite_to_stream', 'composite_to_stream_finish');
+Gio._promisify(Shell.Screenshot.prototype, 'pick_color');
+Gio._promisify(Shell.Screenshot.prototype, 'screenshot');
+Gio._promisify(Shell.Screenshot.prototype, 'screenshot_window');
+Gio._promisify(Shell.Screenshot.prototype, 'screenshot_area');
+Gio._promisify(Shell.Screenshot.prototype, 'screenshot_stage_to_content');
+Gio._promisify(Shell.Screenshot, 'composite_to_stream');
 
 const { loadInterfaceXML } = imports.misc.fileUtils;
 const { DBusSenderChecker } = imports.misc.util;
index dec7adc00759815a542dead95e4447513a03f900..6fcbe67a32d59a736207cdb376e416a6e61ec81a 100644 (file)
@@ -15,10 +15,9 @@ const Util = imports.misc.util;
 
 const { loadInterfaceXML } = imports.misc.fileUtils;
 
-Gio._promisify(Gio.DBusConnection.prototype, 'call', 'call_finish');
-Gio._promisify(NM.Client, 'new_async', 'new_finish');
-Gio._promisify(NM.Client.prototype,
-    'check_connectivity_async', 'check_connectivity_finish');
+Gio._promisify(Gio.DBusConnection.prototype, 'call');
+Gio._promisify(NM.Client, 'new_async');
+Gio._promisify(NM.Client.prototype, 'check_connectivity_async');
 
 const NMConnectionCategory = {
     INVALID: 'invalid',
index d3bb155720ee8bad17b9598a67fd5cb921500222..8f102baffb78929cff0d5b2877269542678c0d0d 100644 (file)
@@ -46,10 +46,8 @@ const GsdWacomProxy = Gio.DBusProxy.makeProxyWrapper(GsdWacomIface);
 
 const WINDOW_DIMMER_EFFECT_NAME = "gnome-shell-window-dimmer";
 
-Gio._promisify(Shell,
-    'util_start_systemd_unit', 'util_start_systemd_unit_finish');
-Gio._promisify(Shell,
-    'util_stop_systemd_unit', 'util_stop_systemd_unit_finish');
+Gio._promisify(Shell, 'util_start_systemd_unit');
+Gio._promisify(Shell, 'util_stop_systemd_unit');
 
 var DisplayChangeDialog = GObject.registerClass(
 class DisplayChangeDialog extends ModalDialog.ModalDialog {
index 329d3870dd6079238fdc64a314a5b1436ae59ca8..09047a939a841d87eaa662476a826eece7c9ed93 100644 (file)
@@ -14,8 +14,8 @@ const { ExtensionState, ExtensionType } = ExtensionUtils;
 const GnomeShellIface = loadInterfaceXML('org.gnome.Shell.Extensions');
 const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface);
 
-Gio._promisify(Gio.DBusConnection.prototype, 'call', 'call_finish');
-Gio._promisify(Shew.WindowExporter.prototype, 'export', 'export_finish');
+Gio._promisify(Gio.DBusConnection.prototype, 'call');
+Gio._promisify(Shew.WindowExporter.prototype, 'export');
 
 function loadInterfaceXML(iface) {
     const uri = 'resource:///org/gnome/Extensions/dbus-interfaces/%s.xml'.format(iface);